package com.lin.java.tool.file.web;


import com.lin.java.tool.common.model.QueryPage;
import com.lin.java.tool.common.model.R;


import com.lin.java.tool.file.service.FileConfigService;
import com.lin.java.tool.file.service.vo.FileConfigVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @作者: 林江
 * @创建时间: 2024/3/21
 * @功能:
 */
@Api(tags = "文件配置")
@RestController
@RequestMapping("/file/config")
public class FileConfigController {

    @Autowired
    private FileConfigService fileConfigService;

    @ApiOperation("文件配置 - 分页查询")
    @PostMapping("list-page")
    public R listPage(@RequestBody QueryPage page) {
        return R.ok(fileConfigService.listPage(page));
    }

    @ApiOperation("文件配置 - 添加")
    @PostMapping("add")
    public R add(@RequestBody @Validated FileConfigVO body) {
        return R.ok(fileConfigService.add(body));
    }

    @ApiOperation("文件配置 - 修改")
    @PostMapping("edit")
    public R edit(@RequestBody @Validated FileConfigVO body) {
        return R.ok(fileConfigService.edit(body));
    }

    @ApiOperation("文件配置 - 修改")
    @GetMapping("/update-status")
    public R updateStatus(@RequestParam("id") Long id, @RequestParam("status") Integer status) {
        fileConfigService.updateStatus(id, status);
        return R.ok();
    }

    @ApiOperation("文件配置 - 删除")
    @GetMapping("delete")
    public R deleteById(Long id) {
        return R.ok(fileConfigService.deleteById(id));
    }
}
